package com.cmz.strategy;

import java.util.Arrays;

/**
 * @author summer
 * @create 2020-03-05 13:07
 */
public class Main {
    public static void main(String[] args) {
//        int[] a = {9,2,3,5,7,1,4};
//        Cat[] a= {new Cat(3,3),new Cat(5,5),new Cat(1,1)};
        Dog[] dogs= {new Dog(6),new Dog(8),new Dog(10)};
        Sorter<Dog> sorter_dogs = new Sorter();
        sorter_dogs.sort(dogs,new DogComparator());
        System.out.println(Arrays.toString(dogs));

        // 根据weight
        Cat[] cats_weight = {new Cat(3,3),new Cat(5,5),new Cat(1,1)};
        Sorter<Cat> sorter_cats_weight = new Sorter();
        sorter_cats_weight.sort(cats_weight,new CatWeightComparator());
        System.out.println(Arrays.toString(cats_weight));

        // 根据height
        Cat[] cats_height = {new Cat(3,3),new Cat(5,5),new Cat(1,1)};
        Sorter<Cat> sorter_cat_cats_heights = new Sorter();
        sorter_cat_cats_heights.sort(cats_height,new CatHeightComparator());
        System.out.println(Arrays.toString(cats_height));

        // lambda
        Cat[] cats_height1 = {new Cat(3,3),new Cat(5,5),new Cat(1,1)};
        Sorter<Cat> cats_height_lambda = new Sorter();
        cats_height_lambda.sort(cats_height1,(o1,o2)->{
            if(o1.height < o2.height) return -1;
            else if (o1.height > o2.height) return 1;
            else return 0;
        });
        System.out.println(Arrays.toString(cats_height1));

    }
}
